﻿// =====================================================================
// <copyright file="PropertyValidationHelperTest.cs" author="David R. Guindo">
// 	Copyright (C) 2013. All rights reserved.
// </copyright>
// =====================================================================
// This code is released under the terms of the Apache 2.0 license, 
// http://apache.org/licenses/LICENSE-2.0.html
// =====================================================================

namespace MyEnterprise.Fwk.Tests
{
    using System;
    using AppBlock.Core;
    using AppBlock.Core.Validations;
    using Microsoft.VisualStudio.TestTools.UnitTesting;

    /// <summary>
    ///     This is a test class for PropertyValidationHelperTest and is intended
    ///     to contain all PropertyValidationHelperTest Unit Tests
    /// </summary>
    [TestClass()]
    public class PropertyValidationHelperTest
    {
        private TestContext testContextInstance;

        /// <summary>
        ///     Gets or sets the test context which provides
        ///     information about and functionality for the current test run.
        /// </summary>
        public TestContext TestContext
        {
            get { return this.testContextInstance; }
            set { this.testContextInstance = value; }
        }

        /// <summary>
        ///     A test for DateInRange
        /// </summary>
        [TestMethod()]
        public void DateInRangeTest()
        {
            IValidation validation =
                new Validation(
                    val =>
                        PropertyValidationHelper.DateInRange(
                            val, "this", DateTime.UtcNow, DateTime.MinValue, DateTime.MaxValue, false));
            Assert.IsTrue(validation.IsValid);
        }

        /// <summary>
        ///     A test for IsInIntervalInt
        /// </summary>
        [TestMethod()]
        public void IsInIntervalIntTest()
        {
            IValidation validation =
                new Validation(val => PropertyValidationHelper.IsInIntervalInt(val, "this", 1, 0, int.MaxValue));
            Assert.IsTrue(validation.IsValid);
        }

        /// <summary>
        ///     A test for IsMayorInt
        /// </summary>
        [TestMethod()]
        public void IsMayorIntTest()
        {
            IValidation validation = new Validation(val => PropertyValidationHelper.IsMayorInt(val, "this", 1, 0));
            Assert.IsTrue(validation.IsValid);
        }

        /// <summary>
        ///     Determines whether [is not null test].
        /// </summary>
        [TestMethod()]
        public void IsNotNullTest()
        {
            IValidation validation = new Validation(val => PropertyValidationHelper.IsNotNull(val, "this", new Object()));
            Assert.IsTrue(validation.IsValid);
        }

        /// <summary>
        ///     A test for IsPositiveInt
        /// </summary>
        [TestMethod()]
        public void IsPositiveIntTest()
        {
            IValidation validation = new Validation(val => PropertyValidationHelper.IsPositiveInt(val, "this", 1));
            Assert.IsTrue(validation.IsValid);
        }

        /// <summary>
        ///     A test for IsPositiveLong
        /// </summary>
        [TestMethod()]
        public void IsPositiveLongTest()
        {
            IValidation validation =
                new Validation(val => PropertyValidationHelper.IsPositiveLong(val, "this", long.MaxValue));
            Assert.IsTrue(validation.IsValid);
        }

        /// <summary>
        ///     A test for IsValidGuid
        /// </summary>
        [TestMethod()]
        public void IsValidGuidTest()
        {
            IValidation validation =
                new Validation(val => PropertyValidationHelper.IsValidGuid(val, "this", Guid.NewGuid()));
            Assert.IsTrue(validation.IsValid);
        }

        /// <summary>
        ///     A test for IsValidIdentifier
        /// </summary>
        public void IsValidIdentifierTestHelper()
        {
            IValidation validation = new Validation(val => PropertyValidationHelper.IsValidIdentifier(val, "this", 1));
            Assert.IsTrue(validation.IsValid);
        }

        /// <summary>
        ///     A test for ValidateString
        /// </summary>
        [TestMethod()]
        public void ValidateStringTest()
        {
            IValidation validation =
                new Validation(val => PropertyValidationHelper.ValidateString(val, "this", "Test", 0, 10, false));
            Assert.IsTrue(validation.IsValid);
        }
    }
}